package com.joshjung.hover.functional
{
    import com.joshjung.hover.interactive.PhysicObject;

    public class Weapon
    {
        //---------------------------------------------------------------------
        //
        //  Variables
        //
        //---------------------------------------------------------------------
        /**
         * The object this weapon is mounted to.
         */
        public var parent : PhysicObject;

        /**
         * The barrels from which this projectile proceeds.
         */
        protected var weaponBarrels : Array;

        //---------------------------------------------------------------------
        //
        //  Constructor
        //
        //---------------------------------------------------------------------
        /**
         *  Constructor
         */
        public function Weapon(parent : PhysicObject, weaponBarrels : Array)
        {
            this.parent = parent;
            this.weaponBarrels = weaponBarrels;
        }

        public function startFiring() : void
        {
            for each (var wb : WeaponBarrel in weaponBarrels)
            {
                wb.startFiring();
                parent.loopList.insert(wb);
            }
        }

        public function stopFiring() : void
        {
            for each (var wb : WeaponBarrel in weaponBarrels)
            {
                wb.stopFiring();
                parent.loopList.remove(wb);
            }
        }
    }
}
